class tButton extends tShape
{
  String myName;
  boolean pressed;
  String onClickFunction;
  
  tButton(int[][] newCoords, color newColor, String newName, String newOnClickFunction)
  {
    super(newCoords, newColor);
    myName = newName;
    pressed = false;
    onClickFunction = newOnClickFunction;
  }
  
  void update(int[] mousePos)
  {
    super.update(mousePos, false);
    if (getMouseDownLeft())
    {
      if (pressed == false && hovered)
      {
        pressed = true;
      }
    }
    else
    {
      if (pressed && hovered)
      {
        this.onClick();
      }
      pressed = false;
    }
  }
  
  void onClick()
  {
    if (onClickFunction == "submit")
    {
      submit();
    }
  }
  
  boolean doDraw()
  {
    if (!super.doDraw())
    {
      return false;
    }
    int w = coords[1][0] - coords[0][0];
    int h = coords[2][1] - coords[0][1];
    int padding = (h - 16)/2;
    writeLargeText(myName, coords[0][0] + padding, coords[0][1] + padding);
    return true;
  }
  
  void writeLargeText(String toWrite, int x, int y)
  {
    PFont font = menuFont;
    textFont(font);
    text(toWrite, x, y);
  }
}

tButton createSubmitButton()
{
  int halfw = screenSize[0]/2;
  int w = 200;
  int h = 50;
  int halfh = screenSize[0]-50;
  int coords[][] = { {halfw-w/2,halfh-h/2}, {halfw+w/2,halfh-h/2}, {halfw+w/2,halfh+h/2}, {halfw-w/2,halfh+h/2} };
  return new tButton(coords, color(100,100,100,200), "Submit", "submit");
}

void submit()
{
}
